package HP.p0831;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class EmployeeTest {
    public static void main(String[] args) {
        //new EmployeeTest().bianLiTest();
        new EmployeeTest().addListTest();
    }

    private void bianLiTest() {
        List<Student> studentList = new ArrayList<>();

        Student s1 = new Student("zs", 11, "haha");
        Student s2 = new Student("ls", 22, "gugu");
        Student s3 = new Student("ww", 33, "33");
        studentList.add(s1);
        studentList.add(s2);
        studentList.add(s3);
        System.out.println("方式一:");
        for (Student s : studentList
                ) {

            System.out.println("s.getName() = " + s.getName());
            System.out.println("s.getAge() = " + s.getAge());
            System.out.println("s.getHobby() = " + s.getHobby());
            System.out.println("---------------------");
        }
        System.out.println("方式二:");
        Iterator<Student> it = studentList.iterator();
        while (it.hasNext()) {
            Student s = it.next();

            System.out.println("s.getName() = " + s.getName());
            System.out.println("s.getAge() = " + s.getAge());
            System.out.println("s.getHobby() = " + s.getHobby());
            System.out.println("---------------------");
        }
        System.out.println("方式三:");
        for (int i = 0; i < studentList.size(); i++) {
            Student s = studentList.get(i);

            System.out.println("s.getName() = " + s.getName());
            System.out.println("s.getAge() = " + s.getAge());
            System.out.println("s.getHobby() = " + s.getHobby());
            System.out.println("----------------------");
        }


    }

    private void addListTest() {
        List list = new ArrayList();
        list.add("1");
        list.add("2");
        for (Object a : list

                ) {
            String b = (String) a;
            System.out.println("b = " + b);
        }

        list.remove(0);
        for (Object a : list

                ) {
            String b = (String) a;
            System.out.println("b = " + b);
        }

        System.out.println(list.contains("2"));

    }

}
